<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        .active {
            background-color: red;
            color: blueviolet;
        }
    </style>
</head>

<body>

    <div id="app">
        <div class="a">
            <ul>
                <li class="item" v-for="item in list" :class="{active:activeele==item.id}">
                    <span @click="change(item.id)">{{item.msg}}</span>
                    <ul v-show="activeele == item.id">
                        <li v-for="item in item.list">
                            {{item.msg}}
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>


</body>
<script>
    new Vue({
        el: "#app",
        data: {
            activeele: 0,
            list: [{ id: 1, msg: "第一", list: [{ id: 11, msg: "第一一" }, { id: 12, msg: "第一二" }] },
            { id: 2, msg: "第二", list: [{ id: 21, msg: "第二一" }, { id: 22, msg: "第二二" }] },
            { id: 3, msg: "第三", list: [{ id: 31, msg: "第三一" }, { id: 32, msg: "第三二" }] }
            ],

        },
        methods: {
            change(id) {
                console.log(this.activeele);
                this.activeele = id;
            }
        }
    })


</script>

</html>